package com.fairytask.ui
{
	import com.fairytask.data.Modulator;
	import com.fairytask.data.ViewObject;
	import com.fairytask.engine.components.ToolTips;
	import com.fairytask.engine.components.button.Button;
	import com.fairytask.engine.components.clip.Clip;
	import com.fairytask.engine.components.group.ViewGroup;
	import com.fairytask.engine.components.list.List;
	import com.fairytask.engine.components.table.Table;
	import com.fairytask.engine.components.table.TableEvent;
	import com.fairytask.engine.components.text.Label;
	import com.fairytask.engine.components.window.Window;
	import com.fairytask.engine.define.CoolDefine;
	import com.fairytask.engine.define.Filter;
	import com.fairytask.engine.define.MoneyDefine;
	import com.fairytask.managers.TipsManage;
	import com.fairytask.net.CustomToClientEvent;
	import com.fairytask.resource.StaticIni;
	import com.fairytask.tools.MoneyTools;
	import com.fairytask.tools.SystemTime;
	import com.fairytask.ui.base.FrameUI;
	import com.fairytask.ui.equipUnit.EquipPart;
	import com.fairytask.ui.item.HeadItem;
	import com.fairytask.ui.item.TimeShow;
	import com.fairytask.ui.main.MainUIManager;
	
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	/**
	 * 竞技场
	 * @author zhut
	 * 
	 */
	public class ArenaUI extends FrameUI
	{
		private static var _self            :ArenaUI;
		private var _model                   :Modulator = Modulator.instance;
		//--窗体控件---------------------------------------------------------------
		public var arenaBG                   :Clip         //竞技场底
		public var silverClip                :Clip;        //银两 文字
		public var goldClip                  :Clip;        //仙玉 文字
		public var moneySilver               :Label;       //银两显示标签
		public var moneyGold                 :Label;       //仙玉显示标签
		public var titleBG                   :MovieClip;   //竞技场排名窗口
		public var titleLab                  :Label;       //竞技场排名显示标签
		public var toptitleBG                :MovieClip;   //表头背景
		public var topRanking                :Clip         //排名 文字
		public var topName                   :Clip         //名称 文字
		public var topRank                   :Clip         //等级 文字
		public var topTable                  :Table;       //排名表格
		public var petBox                    :ViewGroup;   //宠物窗口
		public var roleModeBG                :MovieClip;   //挑战对手窗口
		public var timeBG                    :MovieClip;   //冷却时间窗口
		public var timeClip                  :Clip;        //挑战冷却时间 文字
		public var fightTime                 :TimeShow;    //挑战冷却时间倒计时显示
		public var timeBtn                   :Button;      //刷新冷却时间按钮
		public var fightNumBG                :MovieClip;   //挑战次数窗口
		public var fightNumClip              :Clip         //本日挑战次数 文字
		public var fightNum                  :Label        //本日挑战次数
		public var fightNumBtn               :Button;      //增加挑战次数按钮
		public var fightBG                   :Window       //对手窗口背景
		public var fightGroup                :ViewGroup;   //对手窗口
		public var fightInfoBG               :MovieClip;   //挑战结果窗口
		public var fightResult               :List;        //挑战结果显示文本
		public var shopBtn                   :Button;      //竞技场商店按钮
		public var outBtn                    :Button;      //退出按钮
		public var award1BG                  :MovieClip;   //本次奖品图片窗口
		public var award1                    :MovieClip;   //本次奖品图片
		public var awardInfo1BG              :MovieClip;   //本次奖品信息窗口
		public var awardInfo1                :Label;       //本次奖品信息显示标签
		public var award2BG                  :MovieClip    //下次奖品图片窗口
		public var award2                    :MovieClip;   //下次奖品图片
		public var awardInfo2BG              :MovieClip;   //下次奖品信息窗口
		public var awardInfo2                :Label;       //下次奖品信息显示标签
		public var luckyNumBG                :MovieClip;    //幸运排名号码窗口
		public var luckyClip                 :Clip;        //本次竞技场幸运排名号码为 文字
		public var luckyInfo                 :Label        //幸运排名的说明
		public var luckyNums                 :Label;        //产生的幸运号码显示标签
		public var prizeLabel                :Label;
		public var prizeTime                 :TimeShow      //奖励冷却时间倒计时显示
		//-------------------------------------------------------------------------
		private var awardTips                :Array = []    //奖励物品内容 Tips显示
		//private var _alltime                 :int;          //总挑战次数
		private var oppInfo                  :Array;        //所有对手信息
		private var prizeTimeNum             :Array;        //[挑战冷却持续时间,挑战冷却开始时间]
		private var fightTimeNum             :Array;        //[奖励冷却持续时间,奖励冷却开始时间]
		//public  var isArenaShow              :Boolean=false;//竞技场是否打开
		private var eqPart                   :EquipPart;    //对手信息面板
		private var _nowOppName               :String;      //当前查看对手的名称
		private var _nowOppSex                :int;         //当前查看对手的性别
		private var _oppPetIndex              :Array=[];    //对手宠物战斗位置
		private var _oppPetModel              :Array=[];    //对手宠物模型
		private var vipPrilege                :int;         //vip行为
		private var vipCurStep                :int;         //当前进度
		private var fightTimes                :int;         //非vip挑战次数
		
			
		public static function getInstance():ArenaUI
		{
			if(_self==null)
			{
				_self=new ArenaUI();
			}
			return _self;
		}
		public static function isArena():Boolean
		{
			return Boolean(_self);
		}
		/**
		 * 重写显示事件 
		 * 
		 */
		override public function show(space:String=MIDDLELAYER, onshow:Function=null):void
		{
			if(!isShow)
			{
				//isArenaShow = true;
				//竞技场打开
				//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ARENA_INSERT_PLAYER);
				MainUIManager.getInstance().showMainUI(MainUIManager.ARENA);
				super.show(space,onshow);
				//isArenaShow = true;
			}
		}
		override public function hide(e:*=null):void
		{
			super.hide(e);
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ARENA_CLOSE);
			//isArenaShow = false;
			MainUIManager.getInstance().showMainUI(MainUIManager.CITY);
		}
		/**
		 * 切换面板时关闭(事件系统)
		 * 
		 */
		public function changeHide(e:*=null):void
		{
			if(isShow)
				hide(e);
		}
			
		public function ArenaUI():void
		{
			initInfo();
			initEvent();
			//initSend();	
		}
		private function initInfo():void
		{
			oppInfo = [];
			if(null == eqPart)
			{
				eqPart = new EquipPart();
				eqPart.x = -10;
				eqPart.y = 290;
				//eqPart.bindView(ViewDefine.VIEWPORT_OTHER_EQUIP);
				this.addChild(eqPart);
			}
			fightTime = new TimeShow(0);
			fightTime.x = timeClip.x + 100;
			fightTime.y = timeClip.y;
			windowBG.addChild(fightTime); 
			
			prizeTime = new TimeShow(0);
			prizeTime.x = 620;
			prizeTime.y = 85;
			windowBG.addChild(prizeTime);
			
			prizeTimeNum = [-1,-1];
			fightTimeNum = [-1,-1];
			
			award1.width = award2.width = 35;
			award1.height = award2.height = 32;
			award1.gotoAndStop("normal");
			award2.gotoAndStop("normal");
			award2.filters = [Filter.GRAY];
		}
		/**
		 * 初始化事件
		 * 
		 */
		private function  initEvent():void
		{
			//竞技场排行榜前5排名
			/*_model.addEventListener(CustomToClientEvent.SERVER_CUSTOMMSG_SHOW_TOPLIST,getInfo);
			//玩家排行信息
			_model.addEventListener(CustomToClientEvent.SERVER_CUSTOMMSG_PLAY_LIST,getInfo);
			//幸运排行号码
			_model.addEventListener(CustomToClientEvent.SERVER_CUSTOMMSG_SHOW_LUCK_NUM,getInfo);
			//获取排行奖励信息
			_model.addEventListener(CustomToClientEvent.SERVER_CUSTOMMSG_RANK_PRIZE_MESSAGE,getInfo);
			//挑战对象信息
			_model.addEventListener(CustomToClientEvent.SERVER_CUSTOMMSG_OPPER_LIST,getInfo);
			//点击查看对手信息
			_model.addEventListener(CustomToClientEvent.SERVER_CUSTOMMSG_CHECK_OPPER_MESSAGE,getInfo);
			//竞技场玩家奖励冷却时间
			//int time              剩余冷却时间
			_model.addEventListener(CustomToClientEvent.SERVER_CUSTOMMSG_PRIZE_COOLTIME,getInfo);
			//获取竞技场挑战结果
			_model.addEventListener(CustomToClientEvent.SERVER_CUSTOMMSG_ARENA_RERANK,getInfo);*/
			//竞技场商店
			shopBtn.addEventListener(MouseEvent.CLICK,onOpenShop);
			//刷新冷却时间
			timeBtn.addEventListener(MouseEvent.CLICK,onResetTime);
			//增加挑战次数
			fightNumBtn.addEventListener(MouseEvent.CLICK,onResetNum);
			//预览奖励
			award1.addEventListener(MouseEvent.ROLL_OVER,showTips);
			award1.addEventListener(MouseEvent.ROLL_OUT,hideTips);
			award1.addEventListener(MouseEvent.CLICK,onGetAward);
			award2.addEventListener(MouseEvent.ROLL_OVER,showTips);
			award2.addEventListener(MouseEvent.ROLL_OUT,hideTips);
			//退出按钮
			outBtn.addEventListener(MouseEvent.CLICK,onOut);
			//点击表格，查看前5名装备信息
			topTable.addEventListener(TableEvent.ROW_SELECT,oppEqInfo);
			//点击查看宠物装备信息
			petBox.addItemsEvent(MouseEvent.CLICK,oppPetInfo);
			//绑定数据
			/*bindManager.BindViewProp(model.scene.GetView(ViewDefine.VIEWPORT_PACKAGE),"Gold",setGold);
			bindManager.BindViewProp(model.scene.GetView(ViewDefine.VIEWPORT_PACKAGE),"Silver",setSilver);
			bindManager.BindRecord(model.scene,RecordDefine.COOLREC,addTimer,null);
			bindManager.BindRecord(model.scene,RecordDefine.VIPPRILEGEREC,bindVipTimes,null);
			bindManager.BindProp((Player.getInstance()).data,"ChallengeTime",this,"challengeTime");
			bindManager.BindView(model.scene,ViewDefine.VIEWPORT_OTHER_EQUIP, onAddEquip, onDelEquip);*/
		}
		/**
		 * 发送初始化信息 
		 * 
		 */
		private function initSend():void
		{
			//排行榜前五名
			////NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_QUERY_TOPLIST);
			//当前玩家排名
			////NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_QUERY_PLAYER);
			//竞技场的幸运号码
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_RANK_LUCK_NUM);
			//获得排名奖励信息
			////NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_RANK_PRIZE_MESSAGE);
			//获得挑战对象
			////NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_OPPONENT);
		}
		/**
		 * 获取消息信息
		 * 
		 */
		/*private function getInfo(evt:CustomToClientEvent):void
		{
			//if(isArenaShow)
			show();
			switch(evt.type)
			{
				case CustomToClientEvent.SERVER_CUSTOMMSG_SHOW_TOPLIST:
					ArenaUI.getInstance().getTopFive(evt);
					break;
				case CustomToClientEvent.SERVER_CUSTOMMSG_PLAY_LIST:
					ArenaUI.getInstance().getPlayerList(evt);
					break;
				case CustomToClientEvent.SERVER_CUSTOMMSG_OPPER_LIST:
					ArenaUI.getInstance().getOppr(evt);
					break;
				case CustomToClientEvent.SERVER_CUSTOMMSG_SHOW_LUCK_NUM:
					ArenaUI.getInstance().getLuckNum(evt);
					break;
				case CustomToClientEvent.SERVER_CUSTOMMSG_RANK_PRIZE_MESSAGE:
					ArenaUI.getInstance().getAward(evt);
					break;
				case CustomToClientEvent.SERVER_CUSTOMMSG_CHECK_OPPER_MESSAGE:
					ArenaUI.getInstance().getOppInfo(evt);
					break;
				case CustomToClientEvent.SERVER_CUSTOMMSG_PRIZE_COOLTIME:
					getLuckyGold(evt);
					break;
				case CustomToClientEvent.SERVER_CUSTOMMSG_ARENA_RERANK:
					getResult(evt);
					break;
			}
		}*/
		/**
		 * 设置挑战次数
		 * 
		 */
		public function set challengeTime(val:int):void
		{
			fightTimes = val;
			refurbishFightTime();
		}
		private function bindVipTimes(key:String,val:*):void
		{
			if(val.GetProperties("0")==6)//PRIVILEGE_ADD_ARENA_TIMES = 6
			{
				bindManager.BindObjProp(val,"1",bindT);
				bindManager.BindObjProp(val,"2",bindT);
			}
		}
		private function bindT(key:String,val:int):void
		{
			if(key == "1")
			{
				vipPrilege = val;
			}else
			{
				vipCurStep = val;
			}
			refurbishFightTime();
		}
		private function refurbishFightTime():void
		{
			fightNum.htmlStrByBorder = fightTimes + vipPrilege - vipCurStep + "";
		}
		/**
		 * 获取冷却表中数据
		 * 
		 */
		private function addTimer(key:String,val:*):void
		{
			if(val.GetProperties("0")==CoolDefine.COOL_DOWN_CHALLENGE)
			{
				bindManager.BindObjProp(val,"1",fightT);
				bindManager.BindObjProp(val,"2",fightT);
			}
			if(val.GetProperties("0")==CoolDefine.COOL_DOWN_PRIZE)
			{
				bindManager.BindObjProp(val,"1",prizeT);
				bindManager.BindObjProp(val,"2",prizeT);
			}
		}
		
		/**
		 *绑定奖励冷却时间 
		 * @param key
		 * @param val
		 * 
		 */
		private function prizeT(key:String,val:int):void
		{
			showTime(key,val,prizeTimeNum,prizeTime);
			award1.filters = prizeTime.time == 0?null:[Filter.GRAY];
		}
		/**
		 *绑定挑战冷却时间 
		 * @param key
		 * @param val
		 * 
		 */
		private function fightT(key:String,val:int):void
		{
			showTime(key,val,fightTimeNum,fightTime);
		}
		
		/*private function getLuckyGold(evt:CustomToClientEvent):void
		{
			luckyInfo.htmlStrByBorder = strByWidth(StaticIni.getSwfLangStrVar("1000000104",[evt.pList.shift()]),17);
		}*/
		
		/**
		 *显示倒计时 
		 * @param key
		 * @param val
		 * @param num     倒计时数据 [持续时间，开始时间]
		 * @param addTime 时间显示组件
		 * 
		 */
		private function showTime(key:String,val:int,num:Array,addTime:TimeShow):void
		{
			switch(key)
			{
				case "0":
					break;
				case "1"://冷却时间
				{
					num[0] = val;
					break;
				}
				case "2"://冷却开始时间
				{
					num[1] = val;
					break;
				}
			}
			if(num[0]>-1 && num[1]>-1)
			{
				addTime.time = SystemTime.getLeftTime(num[1]*1000,num[0]*1000)/1000;
				addTime.styleColor(addTime.time==0?"00ff2d":"ff0000");
				num[0] = num[1] = -1;
			}
		}
		
		/**
		 * 增加挑战次数
		 * 
		 */
		private function onResetNum(e:MouseEvent):void
		{
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_BUY_ARENA_TIME);
		}
		/**
		 * 刷新冷却时间
		 * 
		 */
		private function onResetTime(e:MouseEvent):void
		{
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_BUY_COOL_TIME);
		}
		/**
		 * 获取奖励
		 * 
		 */
		private function onGetAward(e:MouseEvent):void
		{
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_RANK_PRIZE);
		}
			
		/**
		 * 打开竞技场商店
		 * 
		 */
		private function onOpenShop(evt:MouseEvent):void
		{
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_ARENA_SHOP,0);
			this.addChild(ArenaShopUI.getInstance());		
		}
		/**
		 * 鼠标移入，显示tips
		 * @param evt
		 * 
		 */
		private function showTips(evt:MouseEvent):void
		{
			if(awardTips[evt.currentTarget == award1?0:1] != null)
				TipsManage.showTips(awardTips[evt.currentTarget == award1?0:1]);
		}
		/**
		 *鼠标移出，撤销tips 
		 * @param evt
		 * 
		 */
		private function hideTips(evt:MouseEvent):void
		{
			ToolTips.hide();
		}
		/**
		 * 退出
		 * 
		 */
		private function onOut(evt:MouseEvent):void
		{
			_self.hide();
		}
		/**
		 * 设置仙玉
		 * 
		 */
		private function setGold(key:String,val:String):void
		{
			moneyGold.htmlStrByBorder = MoneyTools.setMoney(int(val));
		}
		/**
		 * 设置银两
		 * 
		 */
		private function setSilver(key:String,val:String):void
		{
			moneySilver.htmlStrByBorder = MoneyTools.setMoney(int(val));
		}
		public function set nowOppName(val:String):void
		{
			_nowOppName = val
		}
	
		/**
		 * 获取排行榜前5名
		 * @param evt
		 * 
		 */
		public function getTopFive(evt:CustomToClientEvent):void
		{
			/*_self.show();
			topTable.clear();
			for(var i:int=0;i<evt.pList.length;i+=3)
			{
				topTable.addRow([evt.pList[i],StaticIni.getSwfLangStr(evt.pList[i+1]),evt.pList[i+2],evt.pList[i+1]]);
			}*/
		}
		
		/**
		 * 获取玩家排名
		 * @param evt
		 * 
		 */
		public function getPlayerList(evt:CustomToClientEvent):void
		{
			/*evt.pList.push(evt.pList[1]);
			if(evt.pList[0]<1)
			{
				evt.pList[0] = StaticIni.getSwfLangStr("1000000412");//无排名
			}
			topTable.addRowAt(5,evt.pList,null,"00ff2d");*/
		}
		/**
		 *获取对手信息 
		 * @param evt
		 * 
		 */
		public function getOppr(evt:CustomToClientEvent):void
		{
			/*var length:int=evt.pList.length/3;
			for(var i:int=0;i<length;i++)
			{
				if(null == oppInfo[i])
				{
					var opp:ArenaOppInfoUI = new ArenaOppInfoUI();
					oppInfo[i] = opp;
					fightGroup.getItemByIndex(i).addItem(oppInfo[i] as ArenaOppInfoUI);
				}
				(oppInfo[i] as ArenaOppInfoUI).setInfo(evt.pList.shift(),evt.pList.shift(),evt.pList.shift());
			}*/
		}
		/**
		 *点击挑战对手 
		 * @param evt
		 * @param index
		 * 
		 */
		private function fightWithOpp(evt:MouseEvent,index:int):void
		{
			var rank:String = (evt.currentTarget.getItem() as ArenaOppInfoUI).rank.htmlStr;
			hide();
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_BEG_AREAN,int(rank));
		}
		/**
		 *竞技场幸运排名号码 
		 * @param evt
		 * 
		 */
		public function getLuckNum(evt:CustomToClientEvent):void
		{
			/*luckyNums.htmlStr = strByWidth(evt.pList.toString(),20,",");*/
		}
		/**
		 * 获取并显示排行奖励信息
		 * 
		 */
		public function getAward(evt:CustomToClientEvent):void
		{
			/*var length:int = evt.pList.length/7;
			if(length == 1)
				awardInfo2.htmlStrByBorder = "";
			for(var i:int=0;i<length;i++)
			{
				var time:int = evt.pList.shift();//宝箱号
				var val:Array =[];
				val[0] = evt.pList.shift();
				val[1] = evt.pList.shift();
				val[2] = StaticIni.getSwfLangStr(evt.pList.shift());
				val[3] = evt.pList.shift();                         //奖品数目
				val[4] = getMoneyType(evt.pList.shift());           //金钱类型
				val[5] = evt.pList.shift();                         //金钱数目
				(time==0?awardInfo1:awardInfo2).htmlStrByBorder = 
					StaticIni.getSwfLangStrVar(time==0?"1000000415":"1000000416",[val.shift(),val.shift()]);
				awardTips[i] = StaticIni.getSwfLangStrVar("1000000608",val);//奖品内容
			}*/
		}
		/**
		 *请求对手装备及宠物信息 
		 * @param evt
		 * 
		 */
		private function oppEqInfo(evt:Event):void
		{
			var name:String = (evt.currentTarget as Table).selectRow.itemArr[3].labelStr;
			_nowOppName = name;
			//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_CHECK_PLAYER,_nowOppName);
		}
		/**
		 *请求对手宠物信息 
		 * @param evt
		 * @param index
		 * 
		 */
		private function oppPetInfo(evt:MouseEvent,index:int):void
		{
			if(evt.currentTarget.getItem()==null)
				return;
			if(evt.currentTarget.getItem() is HeadItem)
			{
				_nowOppSex = 3;
				//NetMgr.sendCustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_CHECK_PET_MSG,_oppPetIndex[index],_nowOppName);
				eqPart.roleModel = _oppPetModel[index];
			    for(var i:int=0;i<4;i++)
					petBox.getItemByIndex(i).filters = i==index?[Filter.YELLOW_INNER]:null;
			}
		}
		
		/**
		 *清除对手信息面板 
		 * @param clearPet 是否清除宠物头像
		 * 
		 */
		private function clearOppInfo():void
		{
			for(var j:int = 0;j<4;j++)
			{
				petBox.getItemByIndex(j).clear();
				petBox.getItemByIndex(j).filters = null;
			}
			_oppPetModel = [];
			_oppPetIndex = [];
		}
		/**
		 * 获取某个对手装备及宠物信息
		 * 
		 */
		public function getOppInfo(evt:CustomToClientEvent):void
		{
			clearOppInfo();
			
			/*_nowOppSex       = evt.pList.shift();     //对手性别
			eqPart.roleModel = evt.pList.shift();     //人物模型
			
			var length:int= evt.pList.length/2;
			for(var i:int = 0;i<length;i++)
			{
				_oppPetIndex[i] = evt.pList.shift();
				_oppPetModel[i] = evt.pList.shift();
				var head:HeadItem = new HeadItem();
				head.x = head.y =-5;
				head.source = ResConfig.pngPhotoPath + _oppPetModel[i] + ResConfig.iconImg;
				petBox.getItemByIndex(i).addItem(head);
			}*/
		}
		/**
		 *加载对手装备模型 
		 * @param key
		 * @param val
		 * @param data
		 * 
		 */
		private function onAddEquip(key:String, val:ViewObject, data:Object):void
		{
			/*if(val.data.Pos == 2)
			{
				if(val.data.Model!=0)
				{
					eqPart.oppWeaponModel(val.data.Model,_nowOppSex);
				}
				else
				{
					eqPart.weaponModel = 0;
				}
			}*/
		}
		/**
		 *清除对手装备模型 
		 * @param key
		 * @param val
		 * @param data
		 * 
		 */
		private function onDelEquip(key:String, val:ViewObject, data:Object):void
		{
			/*if(val.data.Pos == 2)
			{
				eqPart.weaponModel = 0;
			}*/
		}
			
		/**
		 *获取战斗结果
		 * @param evt
		 * int      reslut	战斗结果
		 * String	play1	玩家1
		 * String	play2	玩家2
		 * int		rank	战斗后的排名
		 * int		time	时间
		 */
		private function getResult(evt:CustomToClientEvent):void
		{
			/*var result:int    = evt.pList.shift();
			var play1 :String = StaticIni.getSwfLangStr(evt.pList.shift());
			var play2 :String = StaticIni.getSwfLangStr(evt.pList.shift());
			var rank  :int    = evt.pList.shift();
			var time  :String = evt.pList.shift()+"-"+evt.pList.shift()+"-"+evt.pList.shift()+"  "+evt.pList.shift()+":";
			var min   :int    = evt.pList.shift();
			time += min<10?("0"+min):min;
			
			var info:String="";
			if(result)
			{
				if(play1 == "0")
					info = StaticIni.getSwfLangStrVar("1000000601",[play2,rank]);
				else if(play2 == "0")
					info = StaticIni.getSwfLangStrVar("1000000602",[play1,rank]);
				else
					info = StaticIni.getSwfLangStrVar("1000000604",[play1,play2,rank]);
			}
			else
			{
				if(play2 == "0")
					info = StaticIni.getSwfLangStrVar("1000000603",[play1,rank]);
				else
					info = StaticIni.getSwfLangStrVar("1000000600",[play2,rank]);
			}
			info += ("       "+time);
			
			if(null == fightResult)
			{
				fightResult   = new List(423,140,true,[{label:info,height:25,skin:""}],"","","left");
				fightResult.x = 268;
				fightResult.y = 390;
				windowBG.addChild(fightResult);
			}
			else
			{
				var item:ListItem = new ListItem(info,420,20);
				item.enabled = false;
				fightResult.addItem(item);
				fightResult.updata();
			}*/
		}
		/**
		 * 根据金钱类型获取金钱中文名
		 * 
		 */
		public function getMoneyType(type:String):String
		{
			switch(int(type))
			{
				case MoneyDefine.CAPITAL_TYPE_SILVER:
					return StaticIni.getSwfLangStr("1000000299");
				case MoneyDefine.CAPITAL_TYPE_BINDSILVER:
					return StaticIni.getSwfLangStr("1000000113");
				case MoneyDefine.CAPITAL_TYPE_GOLD:
					return StaticIni.getSwfLangStr("1000000300");
				case MoneyDefine.CAPITAL_TYPE_BINDGOLD:
					return StaticIni.getSwfLangStr("1000000301");
				case MoneyDefine.CAPITAL_TYPE_SCORE:
					return StaticIni.getSwfLangStr("1000000115");
				case MoneyDefine.CAPITAL_TYPE_CONTRIBUTE:
					return StaticIni.getSwfLangStr("1000000302");
				case MoneyDefine.CAPITAL_TYPE_SHELL:
					return StaticIni.getSwfLangStr("1000000304");
				case MoneyDefine.CAPITAL_TYPE_SPIRIT:
					return StaticIni.getSwfLangStr("1000000305");
				case MoneyDefine.CAPITAL_TYPE_GUILDCONTRIBUTE:
					return StaticIni.getSwfLangStr("1000000303");
			}
			return "";
		}
		/**
		 *指定字符串显示长度 
		 * @param str    需显示的字符串
		 * @param width  指定宽度（字节） 为0表示不限长度
		 * @param split  字符串中的分隔符
		 * @return 
		 * 
		 */
		public function strByWidth(str:String,width:int=0,split:String=""):String
		{
			if(!width)
				return str;
			
			var arr     : Array  = [];
			var rowInfo : String = "";
			var result  : String = "";
			
			arr = str.split(split);
			while(arr.length)
			{
				var element:String = arr.shift() + (arr.length ? split:"");
				if((rowInfo + element).length > width)
				{
					result += (rowInfo + "<br>");
					rowInfo = element;
				}
				else
				{
					rowInfo += element;
				}
			}
			return result + rowInfo;
		}
	}
}
